<template>
    <div class="dialog">
        <el-header title="发布"></el-header>
        <input type="checkbox" v-model="isChecked">匿名访问
        <input type="text" placeholder="请输入用户名" v-model="username">
        <input type="text" placeholder="请输入标题" v-model="title">
        <input type="text" placeholder="请输入内容" v-model="con">
        <button @click="public">发表</button>
    </div>
</template>
<script>
import ElHeader from './elHeader'
import axios from 'axios'
export default {
    components:{
        ElHeader
    },
    data(){
        return {
            title:'',
            username:'',
            con:'',
            isChecked:false
        }
    },
    methods:{
        public(){
            axios.post('/api/add',{username:this.username,con:this.con,title:this.title}).then(res => {
                console.log(res);
                if(res.data.code === 1){
                    this.bus.$emit('closeDialog');
                }
            })
        }
    }
}
</script>
<style>
    .dialog{
        width:100%;
        height:100%;
        position: absolute;
        top:0;
        left:0;
        background: rgba(0,0,0,.8);
    }
</style>

